package com.cxs.controller;

import com.cxs.model.R;
import com.cxs.service.BucketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: cxs
 * 空间管理
 */
@RestController
@RequestMapping("bucket")
public class BucketController {

    @Autowired
    private BucketService bucketService;


    /**
     * 创建一个空间
     * 多租户的话只需要给每一个租户管理员创建一个空间即可
     * 租户内的普通管理员使用这一个空间操作
     *
     * @param bucketName
     * @return
     */
    @PostMapping
    public R<String> addBucket(String bucketName) {
        bucketService.createBucket(bucketName);
        return R.success();
    }


    @GetMapping
    public R<Boolean> existBucket(String bucketName) {
        Boolean flag = bucketService.existBucket(bucketName);
        return R.success(flag);
    }

    @DeleteMapping
    public R<String> deleteBucket(String bucketName) {
        bucketService.removeBucket(bucketName);
        return R.success();
    }


}
